var BASE_URL = 'http://jinzhidata.com/v2'

$(function () {
    // 获取分类名称
    var url = window.location.href
    console.log(url)
    var typeName = decodeURI(new RegExp(BASE_URL + "/pc/resource_list\\.html\\?typeName=(.*)").exec(url)[1])
    $(".subtitle").text(typeName)
    // var typeName = '分类1'
    // 加载报告/资料 todo 此处一次性加载所有的，待修改
    $.ajax({
        url: BASE_URL + "/resource/list",
        data: {
            typeName: typeName,
            page: 0,
            size: 999999
        },
        type: "get",
        contentType: 'application/json',
        dataType: "json",
        success: function (response) {
            var data = response.data
            console.log(data)
            var html = '';
            for (var i = 0; i < data.length; i++) {
                var item = data[i]
                html += '<div class="zhul_sy_zyList clearfix">'
                html += '   <div class="zhul_nzy_limg">'
                html += '       <a href="' + BASE_URL + "/pc/resource.html?resourceId=" + item.resourceId + '" title="' + item.resourceName + '" >'
                html += '           <img src="/img/' + item.resourceCover + '" title="' + item.resourceName + '"/>'
                html += '       </a>'
                html += '   </div>'
                html += '   <div class="zhul_nzy_rinfo">'
                html += '       <div class="zhul_zy_rtop">'
                html += '           <h3 class="zhul_zy_rtit">'
                html += '               <a href="' + BASE_URL + "/pc/resource.html?resourceId=" + item.resourceId + '" title="' + item.resourceName + '">' + item.resourceName + '</a>'
                html += '           </h3>'
                html += '           <p class="zhul_zy_hot2">'
                html += '               <a href="#" target="_self" title="积分">' + item.resourcePrice + '</a> '
                html += '           </p>'
                html += '       </div>'
                html += '       <p class="zhul_zy_fbdate" style="width:auto;">'
                html += '           <span class="zhul_sy_headerBox zhul_pop_parent" uid="0">' + item.resourceAuthorName + '</span>&nbsp;&nbsp;发表于' + formatTime(item.createTime, "yyyy-MM-dd") + '&nbsp;&nbsp;'
                // html += '           <img src="/img/pubimg/n_star_i_3.png">&nbsp;'
                html += '       </p>'
                html += '       <p class="zhul_zy_ltcon2">' + item.resourceIntroduction + '</p>'
                html += '   </div>'
                html += '</div>'
            }
            $(".zhul_nsy_left").html(html)
        }
    })

})

